import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { AppService } from './app.service';
import { RabbitmqModule } from './rabbitmq/rabbitmq.module';
import config from './config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ChargeModule } from './modules/charge/charge.module';
import { RedisModule } from './redis/redis.module';
import { MqttModule } from './mqtt/mqtt.module';
import { ProfitSettlementModule } from './modules/profit-settlement/profit-settlement.module';
import { ChargeCardModule } from './modules/charge-card/charge-card.module';
import { LocalCacheModule } from './local-cache/local-cache.module';
import { DeviceModule } from './modules/device/device.module';
@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal : true,
      load : [config]
    }),
    TypeOrmModule.forRootAsync({
      useFactory: (configService: ConfigService) => configService.get('database'),
      inject: [ConfigService],
    }),
    RabbitmqModule,
    ChargeModule,
    RedisModule,
    MqttModule,
    ProfitSettlementModule,
    ChargeCardModule,
    LocalCacheModule,
    DeviceModule],
  providers: [AppService],
})
export class AppModule {}
